package com.heima.article.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.article.mapper.ApArticleMapper;
import com.heima.article.service.ApArticleService;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.pojos.ApArticle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ApArticleServiceImpl extends ServiceImpl<ApArticleMapper, ApArticle> implements ApArticleService {
    @Autowired
    private ApArticleMapper apArticleMapper;


    @Override
    public ResponseResult loadApArticle(ArticleDto dto, int type) {
        System.out.println("进入方法体！");
        if (dto.getMinBehotTime() ==null) dto.setMinBehotTime(new Date());
        if (dto.getMaxBehotTime() ==null) dto.setMaxBehotTime(new Date());
        if (dto.getSize() ==null) dto.setSize(10);
        if (dto.getTag() ==null) dto.setTag("__all__");
        List<ApArticle> articleList = apArticleMapper.loadApArticle(dto,type);
        System.out.println("articleList = " + articleList);
        return ResponseResult.okResult(articleList);
//        return null;
    }
}
